package com.wooming.studentinfosystem.controller;

import com.wooming.studentinfosystem.service.impl.StudentStatsService;
import com.wooming.studentinfosystem.util.Result;
import com.wooming.studentinfosystem.vo.StatsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Controller层: 学生人数统计
 *
 * @author Wooming
 */
@RestController
@RequestMapping("/api/students")
public class StudentStatsController {

    @Autowired
    private StudentStatsService studentStatsService;

    @GetMapping("/stats")
    public Result<StatsVO> getStudentStats() {
        //前端链接测试代码
//        System.out.println("前端发送统计数据请求");

        return Result.success(studentStatsService.calculateStatistics());
    }
}
